<?php
//发布图文 codecontain 为 1、3
session_start();
require('../conn.php');
require('../functions.php');
require('admin.php');
//获取code和title
if ($_POST) {
	    $user = array();
	    $user['uid'] = guolv($_POST['uid']);
	    $user['phone'] = guolv($_POST['phone']);
		$user['img'] = guolv($_POST['img']);
	    $user['name'] = guolv($_POST['name']);
	    $user['sex'] = guolv($_POST['sex']);
		
	    if($res){
	        echo "<script>alert('新增成功')</script>";
	        echo "<script>location.href='addpublish.php'</script>";
	        exit;
	    }
} ?>

<?php include('head.php') ?>
<link rel="stylesheet" href="../editor/themes/default/default.css"/>
<link rel="stylesheet" href="../editor/plugins/code/prettify.css"/>
<script charset="utf-8" src="../editor/kindeditor.js"></script>
<script charset="utf-8" src="../editor/lang/zh_CN.js"></script>
<script charset="utf-8" src="../editor/plugins/code/prettify.js"></script>
<script charset="utf-8" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>

<div class="container-fluid">
    <div class="row-fluid">
        <?php
        include('left.php'); ?>
        <div class="span9">
            <h1 class="page-title">编辑机器人</h1>

            <div class="well">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#home" data-toggle="tab">机器人信息</a></li>
                </ul>
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane active in" id="home">
                        <form id="tab" action="addpublish.php" method="post">
                            <label>userId(用户id)</label>
                           <select name="uid" id="img">
                               <?php
                                $user = $mysql->query("select * from `user` WHERE `isrobot` = 1");
                                foreach($user as $info):
                               ?>
                               <option name="uid"><?= $info['id']?></option>
                               <?php endforeach;?>
                           </select>
                            <label>用户名</label>
                            <input type="text" id="name" value="" style="width:300px">                         
                            <label>电话</label>
                            <input name="phone" type="text" style="width:300px" name="name" value="<?=$info['phone']?>">
                            <label>性别</label>
                            <?php echo $info['sex'];die();?>
                            <select name="sex">
                            	<?
                            		if($info['sex']=='1'){
                            			print <<<option
                            			<option selected="selected" value="1">1</option>
                            			<option value="2">2</option>
option;
                            		}else{
                            					print <<<option
                            			<option  value="1">1</option>
                            			<option selected="selected" value="2">2</option>
option;
                            		}
                            	?>
                            	
                            </select>
                           <label>用户头像</label>
                           <div style="width: 100px;height: 100px;">
                           		<img id="head" style="width: 100%;" src="http://wx.qlogo.cn/mmopen/uwJswfkmfEJH5r7WxicoZpbQAUwugjQLeOQy9pbu6d058ANR7vD3AMHgNpGIFqxuDiclr4KAS3z7ibaib7fTzE1hvDhFgGEyd3Fv/0"/>
                           		<input style="width: 300px;" type="text" name="img"  value="<?=$info['head']?>" />	
                           </div>
                           <br />
                            <button class="btn btn-primary"><i class="icon-save"></i> 保存</button>
                            
                        </form>
                    </div>
                </div>

            </div>

        </div>
    </div>


</div>

<footer>
    <hr>

    <p class="pull-right"></p>
    <p><!--power by --></p>
</footer>
<script>
    $("#img").change(function(){
        var id = $(this).children('option:selected').val();
        $.get("changeImg.php",{uid:id}, function(data){
            console.log(data);
            console.log(data);
            $("#head").attr("src",data.img);
            $("#name").attr("value",data.name);
        },"json")
    });
   
</script>
<script src="lib/bootstrap/js/bootstrap.js"></script>
</body>
</html>